//
//  main.cpp
//  ex5_22
//
//  Created by baili on 2024/6/1.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    int a[10] = {2,3,7,12,16,35,67,68,90,98};
    int mid,low,high,num,index;
    cout<< "请输入要查的数据：";
    cin >> num;
    low = 0;
    high = 10-1;
    index = 1;
    while (low <= high) {
        mid = (low+high)/2;
        if (num==a[mid]) {
            index = mid;
            break;
        }else if (num<a[mid]){
            high = mid + 1;
        }else
            low = mid;
    }
    if (index == -1) {
        cout<< "未找到\n";
    }else
        cout<< "找到 下标index=" << index << endl;
    return 0;
}
